﻿/**
 * Created by Guochunjiang on 2018/11/25.
 */
(function () {
    cce.LinesNoCenter = function (posints, linColors) {
        cce.DisplayObject.call(this);
        this.posints = posints || null;
        this.linColors = linColors || '#ccc';
        this.width = 0;
        this.height = 0;
        this.x = posints[0].x || -1;
        this.y = posints[0].y || -1;
        this.minX = posints[0].x;
    };

    cce.LinesNoCenter.prototype = Object.create(cce.DisplayObject.prototype);
    cce.LinesNoCenter.prototype.constructor = cce.LinesNoCenter;

    cce.LinesNoCenter.prototype.draw = function () {
        this.context.beginPath();
        this.context.strokeStyle = this.linColors;
        for (var i = 0; i < this.posints.length; i++) {
            var x = this.posints[i].x;
            var y = this.posints[i].y;
            this.context.lineWidth = 1
            this.context.clearRect(x, y,1,1);
            this.context.lineTo(x, y);
        }
        this.context.closePath();
        this.context.stroke();
    };

    cce.LinesNoCenter.prototype.compareTo = function (target) {

        if (target.minX == null) {
            return null;
        }
        if (this.minX < target.minX) {
            return -1;
        }
        if (this.minX == target.minX) {
            return 0;
        }
        if (this.minX > target.minX) {
            return 1;
        }
        return null;
    };

    cce.LinesNoCenter.prototype.comparePointX = function (point) {

        if (point.x == null) {
            return null;
        }
        if (this.minX < point.x) {
            return -1;
        }
        if (this.minX == point.x) {
            return 0;
        }
        if (this.minX > point.x) {
            return 1;
        }
        return null;
    };

    cce.LinesNoCenter.prototype.hasPoint = function (target) {
        if (target.x == null || target.y == null) {
            return false;
        }
        if (this.x + this.width >= target.x && this.y <= target.y && this.y + this.height >= target.y) {
            return true;
        } else {
            return false;
        }
    };

}());